import { useI18n } from '/@/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '/@/components/Table';
import { basMesOperListData } from '../../../../api/bas/mes/oper/basMesOper';

const { t } = useI18n('sys.empUser');

const modalProps = {
  title: t('工序选择'),
};

const searchForm: FormProps = {
  baseColProps: { lg: 6, md: 8 },
  labelWidth: 80,
  schemas: [
    {
      label: t('工序编码'),
      field: 'code',
      component: 'Input',
    },
    {
      label: t('工序名称'),
      field: 'name',
      component: 'Input',
    },
  ],
};

const tableColumns: BasicColumn[] = [
  {
    title: t('工序名称'),
    dataIndex: 'name',
    key: 'a.name',
    sorter: true,
    width: 230,
    align: 'left',
    slot: 'firstColumn',
  },
  {
    title: t('归属车间'),
    dataIndex: 'workShopCode',
    key: 'a.work_shop_code',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('关键工序'),
    dataIndex: 'bkey',
    key: 'a.bkey',
    sorter: true,
    width: 130,
    align: 'center',
    dictType: 'sys_yes_no',
  },
  {
    title: t('计价方式'),
    dataIndex: 'costType',
    key: 'a.cost_type',
    sorter: true,
    width: 130,
    align: 'center',
    dictType: 'mes_price_mode',
  },
  {
    title: t('技能标准'),
    dataIndex: 'techLevel',
    key: 'a.tech_level',
    sorter: true,
    width: 130,
    align: 'center',
    dictType: 'mes_tech_level',
  },
  {
    title: t('技能控制'),
    dataIndex: 'techCtrl',
    key: 'a.tech_ctrl',
    sorter: true,
    width: 130,
    align: 'center',
    dictType: 'mes_tech_ctrl',
  },
  {
    title: t('报工方式'),
    dataIndex: 'reportType',
    key: 'a.report_type',
    sorter: true,
    width: 130,
    align: 'center',
    dictType: 'mes_report_type',
  },
  {
    title: t('是否委外'),
    dataIndex: 'bout',
    key: 'a.bout',
    sorter: true,
    width: 130,
    align: 'center',
    dictType: 'sys_yes_no',
  },
  {
    title: t('是否报工'),
    dataIndex: 'breport',
    key: 'a.breport',
    sorter: true,
    width: 130,
    align: 'center',
    dictType: 'sys_yes_no',
  },
  {
    title: t('是否检验'),
    dataIndex: 'bcheck',
    key: 'a.bcheck',
    sorter: true,
    width: 130,
    align: 'center',
    dictType: 'sys_yes_no',
  },
  {
    title: t('是否上机'),
    dataIndex: 'bmachine',
    key: 'a.bmachine',
    sorter: true,
    width: 130,
    align: 'center',
    dictType: 'sys_yes_no',
  },
  {
    title: t('状态'),
    dataIndex: 'status',
    key: 'a.status',
    sorter: true,
    width: 130,
    align: 'center',
    dictType: 'sys_search_status',
  },
  {
    title: t('备注说明'),
    dataIndex: 'remarks',
    key: 'a.remarks',
    sorter: true,
    width: 130,
    align: 'left',
  },
];

const tableProps: BasicTableProps = {
  api: basMesOperListData,
  beforeFetch: (params) => {
    params['isAll'] = true;
    return params;
  },
  columns: tableColumns,
  formConfig: searchForm,
  rowKey: 'code',
};

export default {
  modalProps,
  tableProps,
  itemCode: 'code',
  itemName: 'name',
};
